home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-04 | 3.6 KB | 118 lines | [TEXT/MPS ] |
- #
- # File: MacWriteII.vu
- #
- # Contains: Sample demo working with MacWrite II 1.1
- #
- # Written by: David Gaxiola
- #
- # Copyright: © 1992 by Apple Computer, Inc., all rights reserved.
- #
- # Change History (most recent first):
- #
- # 3/4/96 JC Modified EditTheText() task to do an exact match on
- # [window o:1 s:dialog]!
- # 7/2/92 DGG Created.
- #
- # To Do:
- #
-
- Libraries "UtilityTasks.vulib","StandardDialogs.vulib","DataUtils.vulib";
-
- (************************************************************************************
- * Task GenerateSomeText()
- * This task will output a message to the currently active window. One may
- * note that this is a modified form of the GenerateSomeText found in the
- * AppleLink.vu script.
- ************************************************************************************)
- task GenerateSomeText()
- begin
- global gTheCatcher;
- global gTheListOfStrings;
-
- numberOfFonts := card collect [menuItem m:"Font"];
-
- type k:{gTheCatcher, returnKey};
- UseKeyboardEquivalent("a");
- UseKeyboardEquivalent("x");
-
- for each singleString in gTheListOfStrings
- begin
- type k:{singleString, returnKey};
- UseKeyboardEquivalent("t");
- select [menuItem o:random(1,9) m:"Style"];
- select [menuItem o:random(1,numberOfFonts) m:"Font"];
- end;
-
- for counter := 1 to 5
- UseKeyboardEquivalent("v");
- end;
-
- (************************************************************************************
- * Task EditTheText()
- * This task will perform a search and replace on the the text in the
- * currently active window. Note that errors in typing may cause this task
- * to fail.
- ************************************************************************************)
- task EditTheText(stringToSearch := "", stringToReplace := "")
- begin
- match [window o:1 r:?docPosition];
- select [menuItem t:/Find∂/Change≈/ m:"Edit"];
- drag [window o:1 t:"Find/Change"] a:{docPosition[1],docPosition[2]};
- type k:{stringToSearch, tabKey, stringToReplace};
- select [button t:"Find Next" w:"Find/Change"];
- wait(2);
- if match [window o:1 s:dialog]!
- begin
- select [button t:"OK" w:[window o:1]];
- println "### Find command failed!";
- close [window t:"Find/Change"];
- end;
- else
- begin
- select [button t:"Change" w:"Find/Change"];
- close [window t:"Find/Change"];
- end;
- end;
-
- (************************************************************************************
- * Task MacWriteIIMain()
- * This is the script body which will control the testing of MacWrite II.
- ************************************************************************************)
- script MacWriteIIMain()
- begin
- # Define variables.
- global gTheCatcher := "and again";
- global gTheListOfStrings :=
- {
- "Welcome to Virtual User 2.0!",
- "We here at Apple are really excited that you chose our product.",
- "It represents a lot of time spent on research and development of",
- "the next step in Automated Testing.",
- "We think you'll find it fun and productive to use,",
- "and hopefully you'll come back to VU again and again."
- };
-
- theSearchString := gTheListOfStrings[4];
- theReplaceString := "this application, which we think is the best in Automated Testing.";
- savedName := "VU MacWriteII Demo";
-
- # Create the new document.
- select [menuItem t:"New" m:"File"];
- GenerateSomeText();
-
- # Save and close it.
- DoSaveAs(savedName);
- close [window t:savedName];
-
- # Reopen the document and edit it.
- select [menuItem t:/Open≈/ m:"File"];
- SelectFromStandardFile({ConcatStrings({savedName[1],savedName[2],savedName[3]})},
- 0);
- EditTheText(theSearchString, theReplaceString);
-
- # Save it again.
- DoSaveAs(savedName);
-
- # Close window.
- close [window t:savedName o:1];
- end;